<!DOCTYPE html>
<html lang="zh_CN">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<script>
		// 全选/全不选
		function selectAll(select) {
			var ids = document.getElementsByName("ids");
			for (var i=0; i < ids.length; i++) {
				ids[i].checked = select;
			}
		}
		// 反选
		function selectRes() {
			var ids = document.getElementsByName("ids");
			for (var i=0; i < ids.length; i++) {
				ids[i].checked = ids[i].checked !== true;
			}
		}
	</script>
</head>

<body>
<table border="1" cellspacing="0">
	<tr>
		<th>
			<button onclick="selectAll(true)">全选</button>
			<button onclick="selectAll(false)">全不选</button>
			<button onclick="selectRes()">反选</button>
		</th>
	</tr>
	<tr>
		<th><label><input type="checkbox" name="ids"></label></th>
	</tr>
	<tr>
		<th><label><input type="checkbox" name="ids"></label></th>
	</tr>
	<tr>
		<th><label><input type="checkbox" name="ids"></label></th>
	</tr>
	<tr>
		<th><label><input type="checkbox" name="ids"></label></th>
	</tr>
	<tr>
		<th><label><input type="checkbox" name="ids"></label></th>
	</tr>
</table>
</body>
</html>